<template>
<div class="changeWallet">
  <el-form ref="form" :model="form" :rules="rules" label-width="92px">
    <el-form-item label="姓名" prop="realName">
      <el-input v-model="form.realName" placeholder="请输入真实姓名"/>
    </el-form-item>
    <el-form-item label="支付宝账号" prop="zfbAccount">
      <el-input v-model="form.zfbAccount" placeholder="请输入支付宝账号"/>
    </el-form-item>
    <el-form-item label="钱包余额:" prop="walletBalance">
      <el-input v-model="form.walletBalance" :disabled="true"></el-input>
    </el-form-item>
    <el-form-item>
      <el-button type="danger" size="mini">充值</el-button>
      <el-button type="danger" size="mini" plain>提现</el-button>
      <el-button type="primary" size="mini" @click="submit">保存</el-button>
      <el-button type="danger" size="mini" @click="close">关闭</el-button>
    </el-form-item>
  </el-form>

  <!-- 修改用户个人钱包信息 -->
  <!-- <el-dialog :title="title" :visible.sync="open" width="460px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="92px">
          <el-row>
              <el-col :span="20">
                  <el-form-item label="姓名" prop="fullName">
                    <el-input v-model="form.fullName" placeholder="请输入姓名" />
                  </el-form-item>
              </el-col>
              <el-col :span="20">
                  <el-form-item label="身份证" prop="formIdd">
                    <el-input v-model="form.formIdd" placeholder="请输入身份证号码" />
                  </el-form-item>
              </el-col>
              <el-col :span="20">
                  <el-form-item label="支付宝账号" prop="alipayAccount">
                    <el-input v-model="form.alipayAccount" placeholder="请输入支付宝账号" />
                  </el-form-item>
              </el-col>
          </el-row>
      </el-form>
        <span style="color:#d10000;">提示：姓名、身份证与支付宝账号必须为同一人</span>
      <div slot="footer" class="dialog-footer">
        <el-button
        type="primary"
        :save="save"
        @click.native.prevent="submitForm">保 存</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
  </el-dialog> -->
</div>
</template>

<script>
import { getWallet, addWallet} from "@/api/system/wallet";
export default {
    data() {
        return {
            open:false,
            title:'修改钱包信息',
            form: {
              realName:'',
              zfbAccount:'',
              walletBalance: undefined,
            },
        rules: {
            realName:[{required: true, trigger: "blur", message: "姓名不能为空"}],
            zfbAccount:[{required: true, trigger: "blur", message: "支付宝账号不能为空"}],
        },
        }
    },
    created() {
      this.getWallet()
    },
    methods: {
      getWallet() {
        getWallet().then(response => {
        if(response.data !== undefined) {
          this.form = response.data
          this.form.walletBalance = this.form.walletBalance/100
        }
      })
      },
    //保存按钮
    submit() {
      addWallet(this.form).then(response => {
        this.msgSuccess("修改成功");
        this.getWallet()
        });
    },
    close() {
      this.$store.dispatch("tagsView/delView", this.$route);
      this.$router.push({ path: "/index" });
    }
    },
}
</script>
